import { createApp } from 'vue';
import { setupRouter } from '@/router';
import { setupStore } from '@/store';

import { setupDirectives } from './directives';
import elementIcon from '@/IconsVue';
import { registerNaiveTools } from '@/utils/global';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import './styles/css-vars.scss';
import App from './App.vue';

async function setupApp() {
    const app = createApp(App);

    /** 挂载pinia状态 */
    setupStore(app);

    /** 挂载路由 */
    await setupRouter(app);

    /** element icon 图表集合 */
    elementIcon(app);

    /** 挂载自定义指令 */
    setupDirectives(app);

    /** 挂载ElementPlus组件的方法至window, 以便在路由钩子函数和请求函数里面调用 */
    registerNaiveTools();

    app.mount('#app');
}

setupApp();
